﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Meraz.Core.Model;

namespace Meraz.Core.Repositories
{
    public interface ITwitterClientRepository : IRepository<TwitterClient, int> { TwitterClient GetByName(string name);}
    public class TwitterClientRepository: EFRepositoryBase<TwitterClient, int>, ITwitterClientRepository
    {
        public override TwitterClient GetById(int id)
        {
            return context.TwitterClients.Where(where1 => where1.ID == id).FirstOrDefault();
        }
        public TwitterClient GetByName(string name)
        {
            return context.TwitterClients.Where(where1 => where1.Name == name).FirstOrDefault();
        }

        public override void Add(TwitterClient entity)
        {
            context.AddToTwitterClients(entity);
        }

        public override void Delete(TwitterClient entity)
        {
            context.TwitterClients.DeleteObject(entity);
        }

        public override List<TwitterClient> All()
        {
            return context.TwitterClients.ToList();
        }
    }
}
